home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 726-750 / 741 / rkrm_lib1 / rkrm_lib1.lha / ASL / filepat.c < prev    next >
C/C++ Source or Header  |  1992-09-03  |  6KB  |  138 lines

  1. ;/* filepat.c - Execute me to compile me with SASC 5.10
  2. LC -b1 -cfistq -v -y -j73 filepat.c
  3. Blink FROM LIB:c.o,filepat.o TO filepat LIBRARY LIB:LC.lib,LIB:Amiga.lib
  4. quit
  5. */
  6.  
  7. /*
  8. Copyright (c) 1992 Commodore-Amiga, Inc.
  9.  
  10. This example is provided in electronic form by Commodore-Amiga, Inc. for
  11. use with the "Amiga ROM Kernel Reference Manual: Libraries", 3rd Edition,
  12. published by Addison-Wesley (ISBN 0-201-56774-1).
  13.  
  14. The "Amiga ROM Kernel Reference Manual: Libraries" contains additional
  15. information on the correct usage of the techniques and operating system
  16. functions presented in these examples.  The source and executable code
  17. of these examples may only be distributed in free electronic form, via
  18. bulletin board or as part of a fully non-commercial and freely
  19. redistributable diskette.  Both the source and executable code (including
  20. comments) must be included, without modification, in any copy.  This
  21. example may not be published in printed form or distributed with any
  22. commercial product.  However, the programming techniques and support
  23. routines set forth in these examples may be used in the development
  24. of original executable software products for Commodore Amiga computers.
  25.  
  26. All other rights reserved.
  27.  
  28. This example is provided "as-is" and is subject to change; no
  29. warranties are made.  All use is at your own risk. No liability or
  30. responsibility is assumed.
  31. */
  32.  
  33. #include <exec/types.h>
  34. #include <intuition/intuition.h>
  35. #include <intuition/screens.h>
  36. #include <graphics/displayinfo.h>
  37. #include <libraries/asl.h>
  38. #include <workbench/startup.h>
  39.  
  40. #include <clib/asl_protos.h>
  41. #include <clib/exec_protos.h>
  42. #include <clib/intuition_protos.h>
  43. #include <stdio.h>
  44.  
  45. #ifdef LATTICE
  46. int CXBRK(void)     { return(0); }  /* Disable Lattice CTRL/C handling */
  47. void chkabort(void) { return; }     /* really */
  48. #endif
  49.  
  50. UBYTE *vers = "$VER: filepat 37.0";
  51.  
  52. struct Library *AslBase = NULL;
  53. struct Library *IntuitionBase = NULL;
  54. struct Screen *screen = NULL;
  55. struct Window *window = NULL;
  56.  
  57. void main(int argc, char **argv)
  58. {
  59.     struct FileRequester *fr;
  60.     struct WBArg *frargs;
  61.     int x;
  62.  
  63.     if (AslBase = OpenLibrary("asl.library", 37L))
  64.     {
  65.         if (IntuitionBase = (struct IntuitionBase *)
  66.                 OpenLibrary("intuition.library", 37L))
  67.         {
  68.             if (screen = (struct Screen *)OpenScreenTags(NULL,
  69.                     SA_DisplayID, HIRESLACE_KEY,
  70.                     SA_Title, "ASL Test Screen",
  71.                     TAG_END))
  72.             {
  73.                 if (window = (struct Window *)OpenWindowTags(NULL,
  74.                         WA_CustomScreen, screen,
  75.                         WA_Title, "Demo Customscreen, File Pattern, Multi-select",
  76.                         WA_Flags, WINDOWDEPTH | WINDOWDRAG,
  77.                         TAG_END))
  78.                 {
  79.                     if (fr = (struct FileRequester *)
  80.                         AllocAslRequestTags(ASL_FileRequest,
  81.                             ASL_Hail, (ULONG)"FilePat/MultiSelect Demo",
  82.                             ASL_Dir,  (ULONG)"libs:",
  83.                             ASL_File, (ULONG)"asl.library",
  84.  
  85.                             /* Initial pattern string for pattern matching */
  86.                             ASL_Pattern, (ULONG)"~(rexx#?|math#?)",
  87.  
  88.                             /* Enable multiselection and pattern match gadget */
  89.                             ASL_FuncFlags, FILF_MULTISELECT | FILF_PATGAD,
  90.  
  91.                             /* This requester comes up on the screen of this
  92.                             ** window (and uses window's message port, if any).
  93.                             */
  94.                             ASL_Window, window,
  95.                             TAG_DONE))
  96.                     {
  97.                         /* Put up file requester */
  98.                         if (AslRequest(fr, 0L))
  99.                         {
  100.                             /* If the file requester's rf_NumArgs field
  101.                             ** is not zero, the user multiselected. The
  102.                             ** number of files is stored in rf_NumArgs.
  103.                             */
  104.                             if (fr->rf_NumArgs)
  105.                             {
  106.                                 /* rf_ArgList is an array of WBArg structures
  107.                                 ** (see <workbench/startup.h>). Each entry in
  108.                                 ** this array corresponds to one of the files
  109.                                 ** the user selected (in alphabetical order).
  110.                                 */
  111.                                 frargs = fr->rf_ArgList;
  112.  
  113.                                 /* The user multiselected, step through
  114.                                 ** the list of selected files.
  115.                                 */
  116.                                 for ( x=0;  x < fr->rf_NumArgs;  x++ )
  117.                                     printf("Argument %d: PATH=%s FILE=%s\n",
  118.                                         x, fr->rf_Dir, frargs[x].wa_Name);
  119.                             }
  120.                             else
  121.                                 /* The user didn't multiselect, use the
  122.                                 ** normal way to get the file name.
  123.                                 */
  124.                                 printf("PATH=%s FILE=%s\n", fr->rf_Dir, fr->rf_File);
  125.                         }
  126.                         /* Done with the FileRequester, better return it */
  127.                         FreeAslRequest(fr);
  128.                     }
  129.                     CloseWindow(window);
  130.                 }
  131.                 CloseScreen(screen);
  132.             }
  133.             CloseLibrary(IntuitionBase);
  134.         }
  135.         CloseLibrary(AslBase);
  136.     }
  137. }
  138.